import * as SSKEYS from '@/common/session-storage-keys'

// 判断环境获取基础地址
export function getBaseUrl(url) {
 const urls = getApp().globalData.config.urls
 let baseUrl = urls.pro
 const appPlatform = uni.getStorageSync(SSKEYS.ACCOUNT_APPLICATION_PLATFORM_KEY)
 // console.log(appPlatform)
 if (appPlatform === 'MP-WEIXIN') {
 	const info = uni.getAccountInfoSync()
 	const envVersion = info.miniProgram.envVersion
 	if (envVersion === 'develop') {
 		baseUrl = urls.dev
 	} else if (envVersion === 'trial') {
 		baseUrl = urls.trial
 	} else if(envVersion ==='release'){
 		baseUrl = urls.pro
 	}
 } else if (appPlatform === 'H5') { //开发环境  生成环境需要切换。
 	if (process.env.NODE_ENV === 'development') {
 	    baseUrl = urls.h5Dev
 	}
 	if (process.env.NODE_ENV === 'production') {
 	    baseUrl = urls.h5Pro 
 	}
 	
 }
  return baseUrl+ url
}